<?php
/* @var $this UserController */
/* @var $model User */
/* @var $form CActiveForm */
?>

<div class="form">

<?php $form=$this->beginWidget('CActiveForm', array(
	'id'=>'user-form',
	'enableAjaxValidation'=>false,
)); ?>

		<p class="note"><?php echo Yii::t('base','Fields with <span class="required">*</span> are required.');?></p>

	<?php echo $form->errorSummary($model); ?>

	<div class="row">
		<?php echo $form->labelEx($model,'user_name'); ?>
		<?php echo $form->textField($model,'user_name',array('size'=>60,'maxlength'=>255)); ?>
		<?php echo $form->error($model,'user_name'); ?>
	</div>
	
		<div class="row">
		<?php echo $form->labelEx($model,'first_name'); ?>
		<?php echo $form->textField($model,'first_name',array('size'=>60,'maxlength'=>255)); ?>
		<?php echo $form->error($model,'first_name'); ?>
	</div>
	
		<div class="row">
		<?php echo $form->labelEx($model,'last_name'); ?>
		<?php echo $form->textField($model,'last_name',array('size'=>60,'maxlength'=>255)); ?>
		<?php echo $form->error($model,'last_name'); ?>
	</div>
	
	
	<div class="row">
		<?php echo $form->labelEx($model,'telephone'); ?>
		<?php echo $form->textField($model,'telephone'); ?>
		<?php echo $form->error($model,'telephone'); ?>
	</div>
	<div class="row">
		<?php echo $form->labelEx($model,'email'); ?>
		<?php echo $form->textField($model,'email'); ?>
		<?php echo $form->error($model,'email'); ?>
	</div>
	<div class="row">
		<?php echo $form->labelEx($model,'password'); ?>
		<?php echo $form->passwordField($model,'password',array('size'=>60,'maxlength'=>255)); ?>
		<?php echo $form->error($model,'password'); ?>
	</div>
	<?php 
	$user_id = Yii::app()->request->getParam(user_id);
	$level = Yii::app()->request->getParam(level);
	if($user_id==""){
				
		if($level==3){
	?>
	<input size="60" maxlength="255" name="User[parentId]" id="User_parentId" type="hidden" value="<?php echo Yii::app()->user->id;?>">
	<?php }else{ ?>
	<input size="60" maxlength="255" name="User[parentId]" id="User_parentId" type="hidden" value="0">	
	<?php }}else{?>
	<input size="60" maxlength="255" name="User[parentId]" id="User_parentId" type="hidden" value="<?php echo $user_id;?>">
	<?php } ?>
	<div class="row">
		<?php echo $form->labelEx($model,'level'); ?>
		<?php
		if($level==1)
		{
			echo $form->dropDownList($model,'level',array(1=>Yii::t('base','Administrator')));
		}elseif($level==2)
		{
			echo $form->dropDownList($model,'level',array(2=>Yii::t('base','Master Account')));
		}elseif($level==3){
			echo $form->dropDownList($model,'level',array(3=>Yii::t('base','Sub Account')));
		}elseif($level==4){
			echo $form->dropDownList($model,'level',array(4=>Yii::t('base','Company')));
		}elseif($level==5){
			echo $form->dropDownList($model,'level',array(5=>Yii::t('base','Staff')));
		}elseif($level==6){
			echo $form->dropDownList($model,'level',array(6=>Yii::t('base','Salesman')));
		}elseif($level==7){
			echo $form->dropDownList($model,'level',array(7=>Yii::t('base','Person')));
		}elseif($level == 9){
			echo $form->dropDownList($model,'level',array(9=>Yii::t('base','Partners')));
		}elseif($level == 10){
			echo $form->dropDownList($model,'level',array(10=>Yii::t('base','Awards')));
		}elseif ($level == 11){
			echo $form->dropDownList($model,'level',array(11=>Yii::t('base','Sales manager')));
		}elseif ($level == 12){
			echo $form->dropDownList($model,'level',array(12=>Yii::t('base','Telesales People')));
		}else{
			if($model->level==1){
				echo $form->dropDownList($model,'level',array(1=>Yii::t('base','Administrator')));
			}elseif($model->level==2){
				echo $form->dropDownList($model,'level',array(2=>Yii::t('base','Master Account')));
			}elseif($model->level==3){
				echo $form->dropDownList($model,'level',array(3=>Yii::t('base','Sub Account')));
			}elseif($model->level==4){
				echo $form->dropDownList($model,'level',array(4=>Yii::t('base','Company')));
			}elseif($model->level==5){
				echo $form->dropDownList($model,'level',array(5=>Yii::t('base','Staff')));
			}elseif($model->level==6){
				echo $form->dropDownList($model,'level',array(6=>Yii::t('base','Salesman')));
			}elseif($model->level==7){
				echo $form->dropDownList($model,'level',array(7=>Yii::t('base','Person')));
			}elseif($model->level == 9){
				echo $form->dropDownList($model,'level',array(9=>Yii::t('base','Partners')));
			}elseif($model->level == 10){
				echo $form->dropDownList($model,'level',array(10=>Yii::t('base','Awards')));
			}
		}	
?>
		<?php echo $form->error($model,'level'); ?>
	</div>
	
    <div>
        <?php echo $form->labelEx($model,'iscustomer'); ?>
		<?php echo $form->dropDownList($model,'iscustomer',array(0=>Yii::t('base','Test Account'),1=>Yii::t('base','Customer Account')) ); ?>		
		<?php echo $form->error($model,'iscustomer'); ?>
    </div>
    <div>
        <?php echo $form->labelEx($model,'invite_user_id');?>
        <?php //echo $form->dropDownList($model,'invite_user_id',array(9=>Yii::t('base','Partners'),6=>Yii::t('base','Salesman'),2=>Yii::t('base','其他用户'),0=>Yii::t('base','无')));?>
        <?php echo $form->error($model,'invite_user_id');?>
    </div>
   
   <?php 
    $level=$_REQUEST['level'];
   if($level==2)
   {?>
    <div>
    <?php 
    echo CHtml::dropDownList('invite_user_id','',array(0=>Yii::t('base','无'),9=>Yii::t('base','Partners'),6=>Yii::t('base','Salesman'),2=>Yii::t('base','其他用户')),
    
    array(    
    'ajax' => array(    
    'type'=>'POST', //request type    
    'url'=>Yii::app()->createUrl('user/getInvite'), //url to call
    'update'=>'#user_id', //selector to update    
    )));
    echo '<br>';
    echo CHtml::dropDownList('user_id','', array());
    ?>
    </div>
    <?php 
    
   }
   elseif ($level!=2)
   {
   ?>
    <div>
    <?php $model2=new PartnerInfo()?>
    <?php echo $form->labelEx($model2,'type');?>
	<?php echo $form->dropDownList($model2,'type',array('1'=>'一级合作商','2'=>'二级合作商','3'=>'三级合作商'))?>	
	</div>
	<?php }?>	
	<div class="row buttons">
		<?php echo CHtml::submitButton($model->isNewRecord ? Yii::t('base','Create') : Yii::t('base','Save')); ?>
	</div>

<?php $this->endWidget(); ?>

</div><!-- form -->